package com.bwie.servicemodule.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.Toast;

import com.bwie.servicemodule.controler.OkGoControler;

/**
 * 带网络请求的activity基类
 * */
public abstract class BaseNetActivity extends BaseActivity implements OkGoControler.HttpListener{

    public OkGoControler okgo;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setListener();
        //初始化网络请求工具类
        okgo = new OkGoControler();
        okgo.setListener(this);
    }

    /**
     * 设置监听器方法
     * */
     protected abstract void setListener();

     //显示loaddialog
    protected void showDialog(){}
    //关闭loaddialog
    protected void disDialog(){}

    //显示toast方法
    protected void showToast(String msg){
        Toast.makeText(this,msg,Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onSuccess(String url, String result) {
        disDialog();
    }

    @Override
    public void onSuccess(String url, String result, int type) {
        disDialog();
    }

    @Override
    public void onErro(String url, String msg) {
        disDialog();
    }
}
